/**
 * 
 */
package any.gwt.client.util;

import java.util.HashMap;
import java.util.Map;

/**
 * TODO: Doc me
 * 
 * @author keke <keke@codehaus.org>
 * @version
 * @revision $Revision:$
 */
public class DispacherContainer {
    private final static EventDispatcher globalDispatcher = new EventDispatcher();
    private static Map                   map;

    public static void addDispatcher(final String name,
            final EventDispatcher dispatcher) {
        if (map == null) {
            map = new HashMap();
        }
        map.put(name, dispatcher);
    }

    public static EventDispatcher getDispatcher(final String name) {
        if (map == null) {
            return null;
        }
        return (EventDispatcher) map.get(name);
    }

    public static EventDispatcher getGlobalDispatcher() {
        return globalDispatcher;
    }

    public static void removeDispatcher(final String name) {
        if (map != null) {
            map.remove(name);
        }
    }
}
